import axios from 'axios'
const service = axios.create({
    // baseURL: process.env.VUE_APP_BASE_URL, 
    baseURL: 'http://43.153.18.14:8888',
    // timeout: 5000 // request timeout
})
// 请求拦截器
service.interceptors.request.use(
    config => {
        const token = localStorage.getItem('token') || ''
        if (token) {
            config.headers['Authorization'] = `Bearer ${token}`
        }
        return config
    },
    error => {
        console.log(error) // for debug
        return Promise.reject(error)
    }
)
//响应拦截器
service.interceptors.response.use(
    response => {
        return response.data
    },
    error => {
        console.log(error) // for debug
        return Promise.reject(error)
    }
)


export default service